package com.adinnet.api.peaseRule.service.impl;

import com.adinnet.api.peaseRule.model.PeaseRule;
import com.adinnet.api.peaseRule.mapper.PeaseRuleMapper;
import com.adinnet.api.peaseRule.service.PeaseRuleService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 金豆规则 服务实现类
 * </p>
 *
 * @author chenjia
 * @since 2020-12-10
 */
@Service
public class PeaseRuleServiceImpl extends ServiceImpl<PeaseRuleMapper, PeaseRule> implements PeaseRuleService {

    @Autowired
    private PeaseRuleMapper peaseRuleMapper;

    @Override
    public List<PeaseRule> getAllPeaseRule() {
        QueryWrapper<PeaseRule> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("deleted",0);
        return peaseRuleMapper.selectList(queryWrapper);
    }

    @Override
    public PeaseRule getPeaseRuleByCode(String code) {
        QueryWrapper<PeaseRule> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("code",code)
                .eq("deleted",0).last("LIMIT 1");
        return peaseRuleMapper.selectOne(queryWrapper);
    }
}
